<template>
  <div class="box5">
    <div class="title">
      <p>上一周游客量趋势图</p>
      <img src="../../images/dataScreen-title.png" alt="" />
    </div>
    <div ref="charts" class="charts"></div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'

//获取节点
const charts = ref()

onMounted(() => {
  //获取echarts类的实例
  const mychart = echarts.init(charts.value)
  //设置实例的配置项
  mychart.setOption({
    //标题组件
    title: {
      text: '访问量',
      textStyle: {
        color: 'white',
        fontSize: 15
      },
      top: 10,
      left: 0
    },
    //布局组件
    grid: {
      left: 60,
      right: 30,
      top: 40,
      bottom: 30
      // containLabel: true
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      splitLine: {
        show: false
      },
      axisLine: {
        show: true
      },

      axisTick: {
        show: true
      },
      data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
    },
    yAxis: {
      splitLine: {
        show: false
      },
      axisLine: {
        show: true
      },

      axisTick: {
        show: true
      }
    },
    series: [
      {
        data: [542, 240, 625, 289, 456, 821, 683],
        type: 'line',
        smooth: true,
        areaStyle: {
          color: {
            type: 'linear',
            x: 0,
            y: 0,
            x2: 0,
            y2: 1,
            colorStops: [
              {
                offset: 0,
                color: 'red' // 0% 处的颜色
              },
              {
                offset: 1,
                color: '#090e57' // 100% 处的颜色
              }
            ],
            global: false // 缺省为 false
          }
        }
      }
    ],
    tooltip: {
      trigger: 'axis',
      show: true,
      textStyle: {
        color: 'red'
      }
    }
  })
})
</script>

<style lang="scss" scoped>
.box5 {
  width: 100%;
  height: 100%;
  background: url(../../images/dataScreen-main-cb.png) no-repeat;
  background-size: 100% 100%;

  .title {
    p {
      color: white;
      font-size: 20px;
    }
  }

  .charts {
    height: calc(100% - 50px);
  }
}
</style>
